package com.mall.admin.controller;

import com.mall.admin.service.OmsOrderReturnApplyService;
import com.mall.commons.utils.PageResult;
import com.mall.commons.utils.R;
import com.mall.dto.OrderReturnDto;
import com.mall.dto.ReturnApplyDto;
import com.mall.vo.ReturnVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {

    @Autowired
    private OmsOrderReturnApplyService omsOrderReturnApplyService;

    //批量删除退货申请
    @PostMapping("/delete")
    public R deleteReturn(List<Long> ids){
        omsOrderReturnApplyService.deleteReturn(ids);
        return R.success("批量删除退货申请",null);
    }

    //分页查询退货申请
    @GetMapping("/list")
    public R list(ReturnApplyDto dto){
        PageResult pageResult = omsOrderReturnApplyService.list(dto);
        return R.success("分页查询退货申请",pageResult);
    }

    //修改退货申请状态
    @PostMapping("/update/status/{id}")
    public R updateStatus(@PathVariable Long id, @RequestBody OrderReturnDto dto){
        omsOrderReturnApplyService.updateStatus(id,dto);
        return R.success("修改退货申请状态",null);
    }
    //获取退货申请详情
    @GetMapping("/{id}")
    public R findReturn(@PathVariable Long id){
        ReturnVo vo = omsOrderReturnApplyService.findReturn(id);
        return R.success("获取退货申请详情",vo);
    }
}
